package com.itheima.dao;

import com.itheima.Permission;
import org.apache.ibatis.annotations.Select;
import java.util.List;

public interface IPermissionDao {

    /**
     * 根据角色id查询所有权限
     * @param roleId
     * @return
     */
    @Select("select * from permission where id in (select permissionId from role_permission where roleId=#{roleId})")
    public List<Permission> findPermissionByRoleID(String roleId);

    /**
     * 查询所有权限
     * @return
     */
    @Select("select * from permission")
    List<Permission> findAll();

    @Select("insert into permission(permissionName,url) values(#{permissionName},#{url})")
    void save(Permission permission);

    @Select("select * from permission where id not in(select permissionId from role_permission where roleId=#{roleId})")
    List<Permission> findOtherPermissionByRoleId(String roleId);
}
